package com.ddd.domain.model.sales;


import com.ddd.application.event.PayEventService;
import com.ddd.domain.share.Entity;
import com.ddd.domain.share.TrackingId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;

import java.util.Objects;

/**
 * 销售的主单据
 */
public class SalesEntity implements Entity {

    /**
     * 订单号
     */
    private String orderId;

    //收银员
    private CashierValueObject cashierValueObject;
    //pos机
    private PosValueObject posValueObject;
    /**
     * 0-待支付，1-支付成功，2-支付失败
     */
    private int status;

    private SalesProductValueObject salesProductValueObject;


    public SalesEntity(String orderId, SalesProductValueObject salesProductValueObject) {
        if (Objects.isNull(salesProductValueObject)){
            throw new RuntimeException("");
        }
        this.orderId = orderId;
        this.salesProductValueObject = salesProductValueObject;
        this.status = 0;
    }

    public void paySuccess(){
        this.status = 1;

    }
    public void payError(){
        this.status = 0;
      }

    @Override
    public boolean sameIdentityAs(Object other) {
        return false;
    }
}
